<template>
  <div>
    <header>
      <nav id="navbar">
        <ul id="option">
          <li class="label">
            <img
              src="./img/山-remove.png"
              alt="山"
              width="50px"
              height="50px"
            />
            <img
              src="./img/河-remove.png"
              alt="河"
              width="50px"
              height="50px"
            />
          </li>
          <li class="item"><a href="#">首页</a></li>
          <li class="item"><a href="#">测一测</a></li>
          <li class="item"><a href="#">测评工具</a></li>
          <li class="item"><a href="#">心林文悦</a></li>
        </ul>
        <a href="http://localhost/psy/login">
          <!-- 链接个人中心 -->
          <img src="./img/flower.jpg" alt="个人头像" id="proson-pic" />
        </a>
      </nav>
    </header>

    <!-- 内容主体 -->
    <main>
      <div class="s1">
        <el-carousel height="93vh" :autoplay="true" :interval="10000">
          <!-- 轮播图 -->
          <CarouselItem :keyNumber="1" :backgroundImage='tower' />
          <CarouselItem :keyNumber="2" :backgroundImage="shore" />
          <CarouselItem :keyNumber="3" :backgroundImage="blueSky" />
          <div class="prompt-box">
            <h1>山河 - 心理测评</h1>
            <p>Shanhe - Psychological Assessment</p>
            <a href="http://localhost/psy/home">点击测试</a>
          </div> 
        </el-carousel>
      </div>

      <div class="s2">
        <!-- 第一层：标题和描述 -->
        <div class="s2-header">
          <h1>个人、机构</h1>
          <p>山河测评的现代化的设计让测评收集成为一件愉悦的事情。</p>
        </div>

        <!-- 第二层：图片 -->
        <div class="s2-images">
          <div>
            <img
              src="https://psystatic.fenxapp.com/uploads/2023/12/23b8b2ef61a416f47624bb6125c04e8d.png"
              alt="1"
            />
            <h3>专业测评</h3>
          </div>
          <div>
            <img
              src="https://psystatic.fenxapp.com/uploads/2023/12/c97cf3c38cab5a161c7723985a348254.png"
              alt="2"
            />
            <h3>质量团队</h3>
          </div>
          <div>
            <img
              src="https://psystatic.fenxapp.com/uploads/2023/12/663720ccb07f1ff98691b88c04ed2e1e-2.png"
              alt="3"
            />
            <h3>机构合作</h3>
          </div>
        </div>
      </div>

      <!-- 可以抽出来做一个card -->
      <div class="s3">
        <!-- 第一层：标题和描述 -->
        <div class="s2-header">
          <h1>功能介绍</h1>
          <p>
            山河测评的团队由一群热衷于心理科学的专业人士组成，他们乐于提供专业的支持和指导，帮助用户和企业得到最大的价值。
          </p>
        </div>

        <!-- 第二层：图片 -->
        <div class="s2-images">
          <div>
            <img
              src="https://psystatic.fenxapp.com/uploads/2023/12/5d99284f1b740ed53691fc7bd4cc9c4b.png"
              alt="1"
            />
            <h3>多平台</h3>
          </div>
          <div>
            <img
              src="https://psystatic.fenxapp.com/uploads/2023/12/6e8af3f7520d1a82e9db114e76c3553c.png"
              alt="2"
            />
            <h3>可交互</h3>
          </div>
          <div>
            <img
              src="https://psystatic.fenxapp.com/uploads/2023/12/8b0b9c4e679950b1f01bd0c1435ffd95.png"
              alt="3"
            />
            <h3>安全保密</h3>
          </div>
        </div>
      </div>

      <p class="spacer">
        每一天都是新的开始<br /><br />"每一天都是一个新的开始，充满了新的希望和可能性。"
      </p>
    </main>

    <hr style="width: 1200px; margin: 0 auto" />
    <footer>
      <div>
        <li><a href="#">关于</a></li>
        <li><a href="#">声明</a></li>
        <li><a href="#">商务</a></li>
        <li><a href="#">更多</a></li>
      </div>
      <p>版权所有 &copy; 2024 - 吉首大学山河心理测评工作室</p>
    </footer>
  </div>
</template>

<script setup>
import { onMounted, onUnmounted } from "vue";

/* webpack处理路径解析和打包 */
import shore from './img/shore.jpg';

import tower from './img/tower.jpg';

import blueSky from './img/blueSky.png';

import CarouselItem from "./components/CarouselItem.vue";

const handleScroll = () => {
  const navbar = document.getElementById("navbar");
  if (navbar) {
    if (window.scrollY > 50) {
      navbar.classList.add("shrink");
    } else {
      navbar.classList.remove("shrink");
    }
  }
};

onMounted(() => {
  window.addEventListener("scroll", handleScroll);
});

onUnmounted(() => {
  window.removeEventListener("scroll", handleScroll);
});
</script>

<style scoped>
* {
  padding: 0;
  margin: 0;
}

html {
  font-size: 16px;
}

header {
  width: 100%;
}

#navbar {
  position: fixed;
  top: 0;
  z-index: 100; /* 导航栏置顶 */
  display: flex;
  width: 100%;
  padding: 0.4rem;

  /* background: linear-gradient(to right, rgb(222, 83, 2), rgb(244, 175, 135)); */
  background-image: url("./img/orangeColor.jpg");

  /* background-position: center; */
  background-size: cover;
  transition: height 1s ease, padding 0.4s ease; /* 平滑过渡效果 */
}

#navbar.shrink {
  height: 55px; /* 导航栏缩小后的高度 */
  padding: 0.2rem 0.4rem; /* 缩小后的内边距 */
}

#navbar #option {
  display: flex;
  flex-grow: 1;
  list-style: none;
}

#navbar #option .label {
  padding-right: 5rem;
  padding-left: 2rem;
}

#navbar #option li {
  padding: 0 1.2rem;
}

#navbar #option li a {
  display: block;
  padding: 1rem 1.2rem;
  font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande",
    "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
  font-size: 1.1rem;
  color: white;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.3s ease, border-radius 0.8s ease;
}

#navbar #option li a:hover {
  background-color: rgba(214, 211, 18, 53.9%);
  border-radius: 1rem;
}

#proson-pic {
  width: 50px;
  height: 50px;
  margin-left: -5rem;
  object-fit: cover;
  border-radius: 50%;
}

main {
  padding-top: 4rem;
}

.prompt-box {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  display: inline-block;
  padding-bottom: 100px;
  text-align: center;
  transform: translate(-50%, -50%); /* 居中 */
}

/* 背景虚化 */
.prompt-box::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background: rgba(255, 255, 255, 10%);
  backdrop-filter: blur(3px);
  border-radius: 1rem;
}

.s1 {
  position: relative;
}

.s1 .prompt-box h1 {
  padding-top: 100px;
  padding-bottom: 10px;
  font-family: "Times New Roman", Times, serif;
  font-size: 5rem;
}

.s1 .prompt-box a {
  padding: 10px 15px;
  color: rgb(0, 0, 0);
  text-decoration: none;
  border: 3px solid #575757;
  border-radius: 5px;
  transition: background-color 0.4s ease;
}

.s1 a:hover {
  background-color: rgba(216, 215, 215, 40.6%);
}

.s1 .prompt-box p {
  padding-block-end: 20px;
  padding-top: 0;
  padding-bottom: 50px;
  margin-top: 0;
  font-size: 20px;
}

.s2 {
  display: flex;
  flex-direction: column;
  padding: 3rem;
  padding-bottom: 4rem;
  background-color: antiquewhite;
}

.s3 {
  /* 临时 */
  padding: 3rem;
  padding-bottom: 4rem;
  background-color: rgba(246, 239, 229, 81.2%);
}

.s2-header {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-bottom: 20px;
  text-align: center;
}

.s2-header h1 {
  margin: 1rem;
  font-size: 3rem;
}

.s2-header p {
  padding-bottom: 2rem;
  font-size: 1rem;
}

.s2-images {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}

.s2-images div {
  width: 20rem;
  text-align: center;
}

.s2-images img {
  display: block;
  width: 100%;
  border-radius: 10px;
}

.s2-images h3 {
  padding: 1rem;
  font-family: "Times New Roman", Times, serif;
  font-size: 1.3rem;
}

.s2 p {
  font-size: 1rem;
}

.spacer {
  margin: 300px; /* 调整间距 */
  font-size: 30px;
}

footer {
  flex-direction: column;
}

footer div {
  display: flex;
  flex-direction: row;
  justify-content: center;
  padding: 20px;
}

footer li {
  padding: 0 1rem;
  margin-top: 1rem;
  list-style: none;
}

footer a {
  color: black;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

footer p {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: black;
  text-align: center;
}

@media screen and (width <= 810px) {
  header .item {
    display: none;
  }

  head .label {
    display: inline;
  }

  header nav {
    justify-content: right;
  }

  .s1 .prompt-box h1 {
    font-size: 4rem;
  }

  .s2 {
    flex-direction: column;
  }
}

@media screen and (width <= 550px) {
  .s1 .prompt-box h1 {
    font-size: 3rem;
  }
}
</style>
